<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>软件下载管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
			if($("#downloadLink").val()){
                $('#linkBody').show();
                $('#url').attr("checked", true);
                $('#appBody').hide();
            } 
			
			$("#title").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
                    if (CKEDITOR.instances.content.getData()=="" && $("#downloadLink").val().trim()==""){
                        top.$.jBox.tip('请填写正文','warning');
                    }else{
                        loading('正在提交，请稍等...');
                        form.submit();
                    }
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/pay/download/">软件下载列表</a></li>
		<li class="active"><a href="<c:url value='${fns:getAdminPath()}/pay/download/form?id=${download.id}'></c:url>">软件下载${not empty question.id?'修改':'添加'}</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="download" action="${ctx}/pay/download/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">标题:</label>
			<div class="controls">
				<form:input path="title" htmlEscape="false" maxlength="200" class="input-xxlarge measure-input required"/>
				<span>
                    <input id="url" type="checkbox" onclick="if(this.checked){$('#linkBody').show();$('#appBody').hide();}else{$('#linkBody').hide();$('#appBody').show();}$('#downloadLink').val()">
                    <label for="url">外部链接</label>
                </span>
			</div>
		</div>
		<%-- <div id="appBody" class="control-group" style="display:block;">
			<label class="control-label">附件:</label>
			<div class="controls">
                <input type="hidden" id=downloadLink name="downloadLink" value="${download.downloadLink}" />
				<sys:ckfinder input="downloadLink" type="apps" uploadPath="/pay/app" selectMultiple="false"/>
			</div>
		</div> --%>
        <div id="linkBody" class="control-group" style="display:none;">
            <label class="control-label">下载链接:</label>
            <div class="controls">
                <form:input path="downloadLink" htmlEscape="false" maxlength="200" class="input-xxlarge"/>
                <span class="help-inline">绝对或相对地址。</span>
            </div>
        </div>
		<div class="control-group">
			<label class="control-label">图片:</label>
			<div class="controls">
                <input type="hidden" id="image" name="image" value="${download.image}" />
				<%-- <sys:ckfinder input="image" type="thumb" uploadPath="/pay/download" selectMultiple="false"/> --%>
				<sys:ckfinder input="image" type="images" uploadPath="/pay/download" selectMultiple="false"/>
				<span class="help-inline">LOGO建议尺寸：347*148像素</span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">描述:</label>
			<div class="controls">
				<form:textarea id="comment" htmlEscape="true" path="comment" rows="6" maxlength="200" class="input-xxlarge"/>
				<%-- <sys:ckeditor replace="comment" uploadPath="/pay/download" /> --%>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">排序:</label>
			<div class="controls">
				<form:input path="sort" htmlEscape="false" maxlength="200" class="input-xlarge"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">发布时间:</label>
			<div class="controls">
				<input id="createDate" name="createDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
					value="<fmt:formatDate value="${download.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">发布状态:</label>
			<div class="controls">
				<form:radiobuttons path="delFlag" items="${fns:getDictList('cms_del_flag')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>
				<span class="help-inline"></span>
			</div>
		</div>
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>